home *** CD-ROM | disk | FTP | other *** search
- Path: uunet!lll-winken!ames!pasteur!ucbvax!decwrl!wyse!mikew
- From: mikew@wyse.wyse.com (Mike Wexler)
- Newsgroups: comp.sources.x
- Subject: v03i025: Ardent Window Manager, Patchlevel 9, Part09/12
- Message-ID: <2075@wyse.wyse.com>
- Date: 20 Feb 89 22:25:15 GMT
- Organization: Wyse Technology, San Jose
- Lines: 1908
- Approved: mikew@wyse.com
-
- Submitted-by: kmw@ardent (Ken Wallich)
- Posting-number: Volume 3, Issue 25
- Archive-name: awm2/part09
-
- #! /bin/sh
- # This is a shell archive. Remove anything before this line, then unpack
- # it by saving it into a file and typing "sh file". To overwrite existing
- # files, type "sh file -c". You can also feed this as standard input via
- # unshar, or by typing "sh <file", e.g.. If this archive is complete, you
- # will see the following message at the end:
- # "End of archive 9 (of 12)."
- # Contents: FocusChng.c Iconify.c MoveOpaque.c Push.c StoreBox.c
- # lockscreen.c menu_sup.c menus/arrow_icon.h menus/menu.h
- # Wrapped by mikew@wyse on Fri Feb 17 10:50:31 1989
- PATH=/bin:/usr/bin:/usr/ucb ; export PATH
- if test -f 'FocusChng.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'FocusChng.c'\"
- else
- echo shar: Extracting \"'FocusChng.c'\" \(6267 characters\)
- sed "s/^X//" >'FocusChng.c' <<'END_OF_FILE'
- X
- X
- X
- X#ifndef lint
- Xstatic char *rcsid_FocusChng_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/FocusChng.c,v 1.2 89/02/07 20:04:50 jkh Exp $";
- X#endif lint
- X
- X#include "X11/copyright.h"
- X/*
- X *
- X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
- X *
- X * Copyright 1987 by Jordan Hubbard.
- X *
- X *
- X * All Rights Reserved
- X *
- X * Permission to use, copy, modify, and distribute this software and its
- X * documentation for any purpose and without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and that
- X * both that copyright notice and this permission notice appear in
- X * supporting documentation, and that the name of Ardent Computer
- X * Corporation or Jordan Hubbard not be used in advertising or publicity
- X * pertaining to distribution of the software without specific, written
- X * prior permission.
- X *
- X */
- X
- X/*
- X * MODIFICATION HISTORY
- X *
- X * 001 -- Jordan Hubbard, U.C. Berkeley.
- X * Hacks for autoraise and titles.
- X * 002 -- Jordan Hubbard, Ardent Computer
- X * Window pixmap changes on focus in/out.
- X * 1.4 -- Fixed Focus In/Out handling. Created LightsOn() and LightsOff()
- X * to break out the actual process of "highlighting".
- X * 1.5 -- Added dynamic installation of colormaps.
- X */
- X
- X
- X#include "awm.h"
- X
- X#ifdef PCS
- X#include <bsd/sys/time.h>
- X#endif /* PCS */
- X#ifdef titan
- X#include <sys/time.h>
- X#endif /* titan */
- X
- XWindow FocusWindow;
- X
- XHandleFocusIn(ev)
- XXEvent *ev;
- X{
- X XEnterWindowEvent *e = (XEnterWindowEvent *)ev;
- X Window w = e->window;
- X AwmInfoPtr awi;
- X XEvent event;
- X
- X Entry("HandleFocusIn")
- X
- X if (!(Hilite || Autoraise || InstallColormap) || Snatched)
- X Leave(FALSE)
- X
- X awi = GetAwmInfo(w);
- X if (!awi) /* probably a menu or something */
- X Leave(FALSE)
- X w = (FrameFocus && awi->frame) ? awi->frame : awi->client;
- X
- X if (e->detail != NotifyInferior && (e->focus || FrameFocus)) {
- X struct timeval foo;
- X
- X if (e->type != FocusIn) {
- X foo.tv_sec = 0;
- X foo.tv_usec = RaiseDelay * 1000;
- X /*
- X * Sleep for awhile to avoid race conditions and give any
- X * potential leave events a chance to get here..
- X */
- X select(0, 0, 0, 0, &foo);
- X /* Did we leave this window already? */
- X if (XCheckTypedWindowEvent(dpy, w, LeaveNotify, &event))
- X if (event.xcrossing.detail != NotifyInferior)
- X Leave(FALSE)
- X /*
- X * Install a colormap, if necessary.
- X */
- X if (InstallColormap) {
- X XWindowAttributes xwa;
- X
- X XGetWindowAttributes(dpy, w, &xwa);
- X XInstallColormap(dpy, xwa.colormap);
- X }
- X
- X /*
- X * If Autoraise is set, raise that puppy..
- X */
- X if (Autoraise && (awi->attrs & AT_RAISE))
- X XRaiseWindow(dpy, (awi->frame) ? awi->frame : awi->client);
- X
- X if (!FocusSetByUser && FocusWindow != awi->client &&
- X (awi->attrs & AT_INPUT)) {
- X if (FrameFocus) {
- X XSetInputFocus(dpy, awi->client, RevertToPointerRoot,
- X CurrentTime);
- X FocusSetByWM = TRUE;
- X }
- X FocusWindow = awi->client;
- X }
- X else
- X Leave(FALSE)
- X }
- X else {
- X FocusWindow = awi->client;
- X FocusSetByWM = FALSE;
- X }
- X LightsOn(awi);
- X }
- X Leave(FALSE)
- X}
- X
- XHandleFocusOut(ev)
- XXEvent *ev;
- X{
- X XLeaveWindowEvent *e = (XEnterWindowEvent *)ev;
- X Window w = e->window;
- X AwmInfoPtr awi;
- X XEvent event;
- X
- X Entry("HandleFocusOut")
- X
- X awi = GetAwmInfo(w);
- X if (!awi) /* probably a menu or something */
- X Leave(FALSE)
- X
- X if (!(Hilite || Autoraise || InstallColormap) || Snatched)
- X Leave(FALSE)
- X
- X w = (FrameFocus && awi->frame) ? awi->frame : awi->client;
- X
- X if (e->detail != NotifyInferior && (e->focus || FrameFocus)) {
- X if (e->type != FocusOut) {
- X /* Did we come back into this window? */
- X if (XCheckTypedWindowEvent(dpy, w, EnterNotify, &event)) {
- X if (event.xcrossing.detail != NotifyInferior)
- X Leave(FALSE)
- X }
- X if (!FocusSetByUser) {
- X if (FrameFocus) {
- X XSetInputFocus(dpy, PointerRoot, RevertToPointerRoot,
- X CurrentTime);
- X FocusSetByWM = TRUE;
- X }
- X FocusWindow = RootWindow(dpy, scr);
- X }
- X else
- X Leave(FALSE)
- X }
- X else {
- X FocusWindow = RootWindow(dpy, scr);
- X FocusSetByWM = FALSE;
- X }
- X if (InstallColormap)
- X XInstallColormap(dpy, DefaultColormap(dpy, scr));
- X LightsOff(awi);
- X }
- X Leave(FALSE)
- X}
- X
- X/*
- X * Turns higlighting off for a window. Counterpart to LightsOn
- X */
- XLightsOff(awi)
- XAwmInfoPtr awi;
- X{
- X Entry("LightsOff")
- X
- X /* set the window border to "gray" stipple */
- X if (awi->attrs & AT_INPUT) {
- X#ifndef RAINBOW
- X if (BorderHilite)
- X SetBorderPixmaps(awi, GrayPixmap);
- X#else
- X if (BorderHilite)
- X SetBorderPixmaps(awi, awi->grayPixmap);
- X#endif
- X if (awi->frame) {
- X if (awi->back && awi->title)
- X XSetWindowBackgroundPixmap(dpy, awi->title,
- X awi->back);
- X if (awi->BC_back && (awi->attrs & AT_BORDER)) {
- X XSetWindowBackgroundPixmap(dpy, awi->frame,
- X awi->BC_back);
- X XClearWindow(dpy, awi->frame);
- X }
- X PaintTitle(awi->title, FALSE);
- X }
- X XSync(dpy, 0);
- X }
- X Leave(FALSE)
- X}
- X
- X
- X/*
- X * Highlight a window. This may involve shuffling pixmaps around
- X * and affecting more than just the client window.
- X */
- XLightsOn(awi)
- XAwmInfoPtr awi;
- X{
- X Entry("LightsOn")
- X
- X if (awi->attrs & AT_INPUT) {
- X#ifndef RAINBOW
- X if (BorderHilite)
- X SetBorderPixmaps(awi, SolidPixmap);
- X#else
- X if (BorderHilite)
- X SetBorderPixmaps(awi, awi->solidPixmap);
- X#endif
- X if (awi->frame) {
- X if (awi->bold && awi->title) {
- X XSetWindowBackgroundPixmap(dpy, awi->title,
- X awi->bold);
- X PaintTitle(awi->title, TRUE);
- X }
- X if (awi->BC_bold && (awi->attrs & AT_BORDER)) {
- X XSetWindowBackgroundPixmap(dpy, awi->frame,
- X awi->BC_bold);
- X XClearWindow(dpy, awi->frame);
- X }
- X XSync(dpy, 0);
- X }
- X }
- X Leave(FALSE)
- X}
- X
- Xvoid SetBorderPixmaps(awi, pix)
- XAwmInfoPtr awi;
- XPixmap pix;
- X{
- X Entry("SetBorderPixmaps")
- X
- X XSetWindowBorderPixmap(dpy, awi->client, pix);
- X if (awi->frame) {
- X if (awi->title)
- X XSetWindowBorderPixmap(dpy, awi->title, pix);
- X XSetWindowBorderPixmap(dpy, awi->frame, pix);
- X }
- X Leave_void
- X}
- END_OF_FILE
- if test 6267 -ne `wc -c <'FocusChng.c'`; then
- echo shar: \"'FocusChng.c'\" unpacked with wrong size!
- fi
- # end of 'FocusChng.c'
- fi
- if test -f 'Iconify.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Iconify.c'\"
- else
- echo shar: Extracting \"'Iconify.c'\" \(7543 characters\)
- sed "s/^X//" >'Iconify.c' <<'END_OF_FILE'
- X
- X
- X
- X#ifndef lint
- Xstatic char *rcsid_Iconify_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/Iconify.c,v 1.2 89/02/07 20:05:12 jkh Exp $";
- X#endif lint
- X
- X#include "X11/copyright.h"
- X/*
- X *
- X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
- X *
- X * Copyright 1987 by Jordan Hubbard.
- X *
- X *
- X * All Rights Reserved
- X *
- X * Permission to use, copy, modify, and distribute this software and its
- X * documentation for any purpose and without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and that
- X * both that copyright notice and this permission notice appear in
- X * supporting documentation, and that the name of Ardent Computer
- X * Corporation or Jordan Hubbard not be used in advertising or publicity
- X * pertaining to distribution of the software without specific, written
- X * prior permission.
- X *
- X */
- X
- X/*
- X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
- X *
- X * All Rights Reserved
- X *
- X * Permission to use, copy, modify, and distribute this software and its
- X * documentation for any purpose and without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and that
- X * both that copyright notice and this permission notice appear in
- X * supporting documentation, and that the name of Digital Equipment
- X * Corporation not be used in advertising or publicity pertaining to
- X * distribution of the software without specific, written prior permission.
- X *
- X *
- X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
- X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- X * SOFTWARE.
- X */
- X
- X
- X
- X/*
- X * MODIFICATION HISTORY
- X *
- X * 000 -- M. Gancarz, DEC Ultrix Engineering Group
- X * 001 -- R. Kittell, DEC Storage A/D May 20, 1986
- X * Add optional warp of mouse to the upper right corner on de-iconify,
- X * and to the icon center on iconify.
- X * 002 -- Loretta Guarino Reid, DEC Ultrix Engineering Group,
- X * Western Software Lab. Port to X11.
- X * 003 -- Jordan Hubbard, Ardent Computer.
- X * Many mods to cope with context manager, titled windows. Almost a total
- X * rewrite.
- X * 1.2 -- Support for IconLabels.. (Isaac Salzman). A few fixes (jkh).
- X */
- X
- X#include "awm.h"
- X
- XBoolean Iconify(window, mask, button, x, y)
- XWindow window; /* Event window. */
- Xint mask; /* Button/key mask. */
- Xint button; /* Button event detail. */
- Xint x, y; /* Event mouse position. */
- X{
- X XWindowAttributes fromInfo; /* info on "from" window */
- X XWindowAttributes toInfo; /* info on "to" window */
- X int mse_x, mse_y; /* Mouse X and Y coordinates. */
- X int sub_win_x, sub_win_y; /* relative Mouse coordinates. */
- X int num_vectors; /* Number of vectors in zap buffer. */
- X unsigned int mmask; /* Mouse state */
- X Window root; /* Mouse root window. */
- X Window from, to; /* from -> to windows */
- X Window sub_win; /* Mouse position sub-window. */
- X XSegment zap[MAX_ZAP_VECTORS]; /* Zap effect vertex buffer. */
- X Boolean dozap; /* local Zap */
- X AwmInfoPtr awi;
- X extern Window MakeIcon();
- X
- X Entry("Iconify")
- X
- X /*
- X * Do not try to iconify the root window.
- X */
- X if (window == RootWindow(dpy, scr))
- X Leave(FALSE)
- X /*
- X * The original idea of zap lines has one flaw. If a window wants
- X * to be created iconic, it should just appear that way without any
- X * fuss. CheckMap() calls us with (win, 0, 0, 0, 0) when this is the
- X * case, so we can special case this to turn off Zap temporarily.
- X * Since we don't want to mess with the global "Zap", we use
- X * "dozap" instead.
- X */
- X dozap = (mask || button || x || y) ? Zap : FALSE;
- X /*
- X * Clear the vector buffer.
- X */
- X if (dozap)
- X bzero(zap, sizeof(zap));
- X
- X /*
- X * Get the mouse cursor position in case we must put a new
- X * icon there.
- X */
- X XQueryPointer(dpy, RootWindow(dpy, scr), &root, &sub_win,
- X &mse_x, &mse_y, &sub_win_x, &sub_win_y, &mmask);
- X
- X
- X /*
- X * Figure out which direction we're going in (icon->window or vica-versa)
- X */
- X awi = GetAwmInfo(window);
- X if (!awi)
- X Leave(FALSE)
- X if (awi->state & ST_ICON) {
- X from = awi->icon;
- X to = (awi->frame) ? awi->frame : awi->client;
- X if (!(awi->state & ST_PLACED)) {
- X PlaceWindow(to, None);
- X XMapWindow(dpy, awi->client);
- X }
- X }
- X else if (awi->state & ST_WINDOW) {
- X from = (awi->frame) ? awi->frame : awi->client;
- X to = (awi->icon) ? awi->icon : MakeIcon(window, mse_x, mse_y, TRUE);
- X }
- X else {
- X printf("Iconify: Window %x has unknown state '%x'\n",
- X awi->client, awi->state);
- X Leave(FALSE)
- X }
- X status = XGetWindowAttributes(dpy, from, &fromInfo);
- X if (status == FAILURE)
- X Leave(FALSE)
- X status = XGetWindowAttributes(dpy, to, &toInfo);
- X if (status == FAILURE)
- X Leave(FALSE)
- X
- X /*
- X * Store the zap vector buffer.
- X */
- X if (dozap) {
- X num_vectors =
- X StoreZap(zap,
- X fromInfo.x - 1,
- X fromInfo.y - 1,
- X fromInfo.x + fromInfo.width +
- X (fromInfo.border_width << 1),
- X fromInfo.y + fromInfo.height +
- X (fromInfo.border_width << 1),
- X toInfo.x - 1,
- X toInfo.y - 1,
- X toInfo.x + toInfo.width +
- X (toInfo.border_width << 1),
- X toInfo.y + toInfo.height +
- X (toInfo.border_width << 1));
- X }
- X if (awi->state & ST_ICON) {
- X if (!awi->frame)
- X XRemoveFromSaveSet(dpy, awi->client);
- X awi->state ^= ST_ICON;
- X awi->state |= ST_WINDOW;
- X#ifdef WMSTATE
- X awi->wm_state.state=NormalState;
- X XChangeProperty(dpy,awi->client,wm_state_atom,wm_state_atom,32,
- X PropModeReplace,(char *) &awi->wm_state,2);
- X#endif /* WMSTATE */
- X }
- X else if (awi->state & ST_WINDOW) {
- X XAddToSaveSet(dpy, awi->client);
- X awi->state ^= ST_WINDOW;
- X awi->state |= ST_ICON;
- X#ifdef WMSTATE
- X awi->wm_state.state=IconicState;
- X XChangeProperty(dpy,awi->client,wm_state_atom,wm_state_atom,32,
- X PropModeReplace,(char *) &awi->wm_state,2);
- X#endif /* WMSTATE */
- X }
- X else
- X fprintf(stderr, "Window state for window %x got munged!\n",
- X awi->client);
- X /*
- X * Map the target.
- X */
- X XMapRaised(dpy, to);
- X if (dozap) {
- X /*
- X * Draw the zap lines.
- X */
- X DrawZap();
- X }
- X /*
- X * Unmap the "from" window.
- X */
- X XUnmapWindow(dpy, from);
- X XFlush(dpy);
- X /*
- X * Optionally warp the mouse to the upper right corner of the
- X * window.
- X */
- X if (WarpOnDeIconify && awi->state & ST_WINDOW) {
- X int y;
- X
- X y = (toInfo.height >= 10) ? 10 : toInfo.height / 2;
- X if (awi->frame) { /* compensate for title */
- X XWindowAttributes xwa;
- X XGetWindowAttributes(dpy, awi->title, &xwa);
- X y += xwa.height + 2;
- X }
- X status = XWarpPointer (dpy, None, to,
- X 0, 0, 0, 0,
- X toInfo.width >= 7 ?
- X toInfo.width - 7 : toInfo.width / 2,
- X y);
- X }
- X
- X if (WarpOnIconify && awi->state & ST_ICON)
- X status = XWarpPointer (dpy, None, to,
- X 0, 0, 0, 0,
- X toInfo.width / 2, toInfo.height / 2);
- X Leave(FALSE)
- X}
- END_OF_FILE
- if test 7543 -ne `wc -c <'Iconify.c'`; then
- echo shar: \"'Iconify.c'\" unpacked with wrong size!
- fi
- # end of 'Iconify.c'
- fi
- if test -f 'MoveOpaque.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'MoveOpaque.c'\"
- else
- echo shar: Extracting \"'MoveOpaque.c'\" \(5422 characters\)
- sed "s/^X//" >'MoveOpaque.c' <<'END_OF_FILE'
- X
- X
- X
- X#ifndef lint
- Xstatic char *rcsid_MoveOpaque_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/MoveOpaque.c,v 1.2 89/02/07 21:23:00 jkh Exp $";
- X#endif lint
- X
- X#include "X11/copyright.h"
- X/*
- X *
- X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
- X *
- X * Copyright 1987 by Jordan Hubbard.
- X *
- X *
- X * All Rights Reserved
- X *
- X * Permission to use, copy, modify, and distribute this software and its
- X * documentation for any purpose and without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and that
- X * both that copyright notice and this permission notice appear in
- X * supporting documentation, and that the name of Ardent Computer
- X * Corporation or Jordan Hubbard not be used in advertising or publicity
- X * pertaining to distribution of the software without specific, written
- X * prior permission.
- X *
- X */
- X
- X/*
- X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
- X *
- X * All Rights Reserved
- X *
- X * Permission to use, copy, modify, and distribute this software and its
- X * documentation for any purpose and without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and that
- X * both that copyright notice and this permission notice appear in
- X * supporting documentation, and that the name of Digital Equipment
- X * Corporation not be used in advertising or publicity pertaining to
- X * distribution of the software without specific, written prior permission.
- X *
- X *
- X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
- X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- X * SOFTWARE.
- X */
- X
- X
- X
- X/*
- X * MODIFICATION HISTORY
- X *
- X * 000 -- M. Gancarz, DEC Ultrix Engineering Group
- X * 001 -- Loretta Guarino Reid, DEC Ultrix Engineering Group,
- X * Western Software Lab. Convert to X11.
- X * 002 -- Jordan Hubbard, Ardent Computer
- X * Changed to work with awm.
- X */
- X
- X#include "awm.h"
- X
- X/*ARGSUSED*/
- XBoolean MoveOpaque(window, mask, button, x, y)
- XWindow window; /* Event window. */
- Xint mask; /* Button/key mask. */
- Xint button; /* Button event detail. */
- Xint x, y; /* Event mouse position. */
- X{
- X int prev_x, prev_y; /* Previous mouse location. */
- X int rbound, dbound; /* potential right/down boundries */
- X int cur_x, cur_y; /* Current mouse location. */
- X int win_x, win_y; /* Current window location. */
- X int root_x; /* Root window X location. */
- X int root_y; /* Root window Y location. */
- X int ptrmask; /* state of ptr when queried */
- X XWindowAttributes window_info; /* Event window information. */
- X Window sub_window; /* Query mouse event sub-window. */
- X Window root; /* Query mouse event root. */
- X XEvent button_event; /* Button event packet. */
- X extern void grab_pointer();
- X extern void ungrab_pointer();
- X
- X Entry("MoveOpaque")
- X
- X /*
- X * Do not try to move the root window.
- X */
- X if (window == RootWindow(dpy, scr))
- X Leave(FALSE)
- X
- X /*
- X * Change the cursor.
- X */
- X grab_pointer();
- X
- X /*
- X * Gather info on the event window.
- X */
- X status = XGetWindowAttributes(dpy, window, &window_info);
- X if (status == FAILURE)
- X Leave(FALSE)
- X
- X /*
- X * Initialize movement variables.
- X */
- X prev_x = cur_x = x;
- X prev_y = cur_y = y;
- X win_x = window_info.x;
- X win_y = window_info.y;
- X rbound = ScreenWidth - (window_info.width + window_info.border_width);
- X dbound = ScreenHeight - (window_info.height + window_info.border_width);
- X
- X /*
- X * Main loop.
- X */
- X while (TRUE) {
- X
- X /*
- X * Check to see if we have a change in mouse button status.
- X * This is how we get out of this "while" loop.
- X */
- X if (XCheckMaskEvent(dpy,
- X ButtonPressMask | ButtonReleaseMask,
- X &button_event)) {
- X
- X /*
- X * If the button event was something other than the
- X * release of the original button pressed, then move the
- X * window back to where it was originally.
- X */
- X if ((button_event.type != ButtonRelease) ||
- X (((XButtonReleasedEvent *)&button_event)->button
- X != button)) {
- X ResetCursor(button);
- X XMoveWindow(dpy, window, window_info.x, window_info.y);
- X }
- X ungrab_pointer();
- X Leave(TRUE);
- X }
- X
- X /*
- X * Take care of all the little things that have changed;
- X * i.e., move the window, if necessary.
- X */
- X XQueryPointer(dpy, RootWindow(dpy, scr),
- X &root, &sub_window, &root_x, &root_y, &cur_x, &cur_y,
- X &ptrmask);
- X if ((cur_x != prev_x) || (cur_y != prev_y)) {
- X win_x += (cur_x - prev_x);
- X win_y += (cur_y - prev_y);
- X#ifdef titan /* align to 5x4 */
- X win_x = ((win_x + 3) / 5) * 5;
- X win_y = ((win_y + 2) / 4) * 4;
- X#endif /* titan */
- X if (Wall) {
- X if (win_x < 0)
- X win_x = 0;
- X else if (win_x > rbound)
- X win_x = rbound;
- X if (win_y < 0)
- X win_y = 0;
- X else if (win_y > dbound)
- X win_y = dbound;
- X }
- X XMoveWindow(dpy, window, win_x, win_y);
- X prev_x = cur_x;
- X prev_y = cur_y;
- X }
- X }
- X}
- END_OF_FILE
- if test 5422 -ne `wc -c <'MoveOpaque.c'`; then
- echo shar: \"'MoveOpaque.c'\" unpacked with wrong size!
- fi
- # end of 'MoveOpaque.c'
- fi
- if test -f 'Push.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'Push.c'\"
- else
- echo shar: Extracting \"'Push.c'\" \(5313 characters\)
- sed "s/^X//" >'Push.c' <<'END_OF_FILE'
- X
- X
- X
- X#ifndef lint
- Xstatic char *rcsid_Push_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/Push.c,v 1.2 89/02/07 21:23:21 jkh Exp $";
- X#endif lint
- X
- X#include "X11/copyright.h"
- X/*
- X *
- X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
- X *
- X * Copyright 1987 by Jordan Hubbard.
- X *
- X *
- X * All Rights Reserved
- X *
- X * Permission to use, copy, modify, and distribute this software and its
- X * documentation for any purpose and without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and that
- X * both that copyright notice and this permission notice appear in
- X * supporting documentation, and that the name of Ardent Computer
- X * Corporation or Jordan Hubbard not be used in advertising or publicity
- X * pertaining to distribution of the software without specific, written
- X * prior permission.
- X *
- X */
- X
- X/*
- X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
- X *
- X * All Rights Reserved
- X *
- X * Permission to use, copy, modify, and distribute this software and its
- X * documentation for any purpose and without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and that
- X * both that copyright notice and this permission notice appear in
- X * supporting documentation, and that the name of Digital Equipment
- X * Corporation not be used in advertising or publicity pertaining to
- X * distribution of the software without specific, written prior permission.
- X *
- X *
- X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
- X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- X * SOFTWARE.
- X */
- X
- X
- X
- X/*
- X * MODIFICATION HISTORY
- X *
- X * 000 -- M. Gancarz, DEC Ultrix Engineering Group
- X * 001 -- Loretta Guarino Reid, DEC Ultrix Engineering Group,
- X Western Software Lab. Convert to X11.
- X */
- X
- X#include "awm.h"
- X
- X#define SHOVE_DOWN 1
- X#define SHOVE_UP 2
- X#define SHOVE_LEFT 3
- X#define SHOVE_RIGHT 4
- X
- Xextern Boolean ShoveAll();
- X
- X/*ARGSUSED*/
- XBoolean ShoveDown(window, mask, button, x, y)
- XWindow window; /* Event window. */
- Xint mask; /* Button/key mask. */
- Xint button; /* Button event detail. */
- Xint x, y; /* Event mouse position. */
- X{
- X Entry("ShoveDown")
- X
- X Leave(ShoveAll(window, SHOVE_DOWN))
- X}
- X
- X/*ARGSUSED*/
- XBoolean ShoveUp(window, mask, button, x, y)
- XWindow window; /* Event window. */
- Xint mask; /* Button/key mask. */
- Xint button; /* Button event detail. */
- Xint x, y; /* Event mouse position. */
- X{
- X Entry("ShoveUp")
- X
- X Leave(ShoveAll(window, SHOVE_UP))
- X}
- X
- X/*ARGSUSED*/
- XBoolean ShoveLeft(window, mask, button, x, y)
- XWindow window; /* Event window. */
- Xint mask; /* Button/key mask. */
- Xint button; /* Button event detail. */
- Xint x, y; /* Event mouse position. */
- X{
- X Entry("ShoveLeft")
- X
- X Leave(ShoveAll(window, SHOVE_LEFT))
- X}
- X
- X/*ARGSUSED*/
- XBoolean ShoveRight(window, mask, button, x, y)
- XWindow window; /* Event window. */
- Xint mask; /* Button/key mask. */
- Xint button; /* Button event detail. */
- Xint x, y; /* Event mouse position. */
- X{
- X Entry("ShoveRight")
- X
- X Leave(ShoveAll(window, SHOVE_RIGHT))
- X}
- X
- XBoolean ShoveAll(w, direction)
- XWindow w;
- Xint direction;
- X{
- X XWindowAttributes winfo; /* Event window information. */
- X int xofs, yofs; /* Movement offsets. */
- X int x, y; /* New window position. */
- X
- X Entry("ShoveAll")
- X
- X /*
- X * Do not try to move the root window.
- X */
- X if (w == RootWindow(dpy, scr))
- X Leave(FALSE)
- X
- X /*
- X * Gather info on the event window.
- X */
- X status = XGetWindowAttributes(dpy, w, &winfo);
- X if (status == FAILURE) Leave(FALSE)
- X if (!Pushval && Push)
- X Pushval = DEF_PUSH;
- X
- X /*
- X * Calculate the movement offsets.
- X */
- X switch(direction) {
- X case SHOVE_DOWN:
- X xofs = 0;
- X yofs = Push ? (winfo.height / Pushval) : Pushval;
- X break;
- X case SHOVE_UP:
- X xofs = 0;
- X yofs = 0 - (Push ? (winfo.height / Pushval) : Pushval);
- X break;
- X case SHOVE_LEFT:
- X xofs = 0 - (Push ? (winfo.width / Pushval) : Pushval);
- X yofs = 0;
- X break;
- X case SHOVE_RIGHT:
- X xofs = Push ? (winfo.width / Pushval) : Pushval;
- X yofs = 0;
- X break;
- X }
- X
- X /*
- X * Calculate the new window position.
- X */
- X x = winfo.x + xofs;
- X y = winfo.y + yofs;
- X
- X /*
- X * Normalize the new window coordinates so we don't
- X * lose the window off the edge of the screen.
- X */
- X if (x < (0 - winfo.width + CURSOR_WIDTH - (winfo.border_width << 1)))
- X x = 0 - winfo.width + CURSOR_WIDTH - (winfo.border_width << 1);
- X if (y < (0 - winfo.height + CURSOR_HEIGHT - (winfo.border_width << 1)))
- X y = 0 - winfo.height + CURSOR_HEIGHT - (winfo.border_width << 1);
- X if (x > (ScreenWidth - CURSOR_WIDTH))
- X x = ScreenWidth - CURSOR_WIDTH;
- X if (y > (ScreenHeight - CURSOR_HEIGHT))
- X y = ScreenHeight - CURSOR_HEIGHT;
- X
- X /*
- X * Move the window into place.
- X */
- X XMoveWindow(dpy, w, x, y);
- X
- X Leave(FALSE)
- X}
- END_OF_FILE
- if test 5313 -ne `wc -c <'Push.c'`; then
- echo shar: \"'Push.c'\" unpacked with wrong size!
- fi
- # end of 'Push.c'
- fi
- if test -f 'StoreBox.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'StoreBox.c'\"
- else
- echo shar: Extracting \"'StoreBox.c'\" \(5241 characters\)
- sed "s/^X//" >'StoreBox.c' <<'END_OF_FILE'
- X
- X
- X
- X#ifndef lint
- Xstatic char *rcsid_StoreBox_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/StoreBox.c,v 1.1 89/01/23 15:34:53 jkh Exp $";
- X#endif lint
- X
- X#include "X11/copyright.h"
- X/*
- X *
- X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
- X *
- X * Copyright 1987 by Jordan Hubbard.
- X *
- X *
- X * All Rights Reserved
- X *
- X * Permission to use, copy, modify, and distribute this software and its
- X * documentation for any purpose and without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and that
- X * both that copyright notice and this permission notice appear in
- X * supporting documentation, and that the name of Ardent Computer
- X * Corporation or Jordan Hubbard not be used in advertising or publicity
- X * pertaining to distribution of the software without specific, written
- X * prior permission.
- X *
- X */
- X
- X/*
- X * Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
- X *
- X * All Rights Reserved
- X *
- X * Permission to use, copy, modify, and distribute this software and its
- X * documentation for any purpose and without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and that
- X * both that copyright notice and this permission notice appear in
- X * supporting documentation, and that the name of Digital Equipment
- X * Corporation not be used in advertising or publicity pertaining to
- X * distribution of the software without specific, written prior permission.
- X *
- X *
- X * DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
- X * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
- X * DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
- X * ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
- X * WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
- X * ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
- X * SOFTWARE.
- X */
- X
- X
- X
- X/*
- X * MODIFICATION HISTORY
- X *
- X * 000 -- M. Gancarz, DEC Ultrix Engineering Group
- X * 001 -- Loretta Guarino Reid, DEC Ultrix Engineering Group,
- X Western Software Lab. Convert to X11.
- X * 002 -- Jordan Hubbard, Ardent Computer
- X * Additional boxes for titled windows.
- X */
- X
- X/*
- X * StoreBox - This subroutine is used by the X Window Manager (xwm)
- X * to store the vertices for the resize / movement box in a vertex list.
- X */
- X
- X#include "awm.h"
- X
- X/*
- X * Store the vertices for the resize movement box (on a titled window)
- X * in a vertex list.
- X */
- Xint StoreTitleBox(box, ulx, uly, lrx, lry)
- Xregister XSegment box[];
- Xint ulx; /* Upper left X coordinate. */
- Xint uly; /* Upper left Y coordinate. */
- Xint lrx; /* Lower right X coordinate. */
- Xint lry; /* Lower right Y coordinate. */
- X{
- X Entry("StoreTitleBox");
- X
- X /*
- X * Xor in.
- X */
- X
- X box[0].x1 = ulx; box[0].y1 = uly;
- X box[0].x2 = lrx; box[0].y2 = uly;
- X
- X box[1].x1 = ulx; box[1].y1 = uly + titleHeight + 2;
- X box[1].x2 = lrx; box[1].y2 = uly + titleHeight + 2;
- X
- X box[2].x1 = lrx; box[2].y1 = uly;
- X box[2].x2 = lrx; box[2].y2 = lry;
- X
- X box[3].x1 = lrx; box[3].y1 = lry;
- X box[3].x2 = ulx; box[3].y2 = lry;
- X
- X box[4].x1 = ulx; box[4].y1 = lry;
- X box[4].x2 = ulx; box[4].y2 = uly;
- X
- X
- X /*
- X * If we freeze the screen, don't bother to xor out.
- X */
- X if (Freeze)
- X Leave(5)
- X
- X /*
- X * Xor out.
- X */
- X box[4].x1 = ulx; box[4].y1 = uly;
- X box[4].x2 = lrx; box[4].y2 = uly;
- X
- X box[5].x1 = ulx; box[5].y1 = uly + titleHeight + 2;
- X box[5].x2 = lrx; box[5].y2 = uly + titleHeight + 2;
- X
- X box[6].x1 = lrx; box[6].y1 = uly;
- X box[6].x2 = lrx; box[6].y2 = lry;
- X
- X box[7].x1 = lrx; box[7].y1 = lry;
- X box[7].x2 = ulx; box[7].y2 = lry;
- X
- X box[8].x1 = ulx; box[8].y1 = lry;
- X box[8].x2 = ulx; box[8].y2 = uly;
- X
- X
- X /*
- X * Total number of vertices is 9.
- X */
- X Leave(9)
- X}
- X
- X/*
- X * Store the vertices for the resize movement box in a vertex list.
- X */
- Xint StoreBox(box, ulx, uly, lrx, lry)
- Xregister XSegment box[];
- Xint ulx; /* Upper left X coordinate. */
- Xint uly; /* Upper left Y coordinate. */
- Xint lrx; /* Lower right X coordinate. */
- Xint lry; /* Lower right Y coordinate. */
- X{
- X Entry("StoreBox");
- X
- X /*
- X * Xor in.
- X */
- X
- X box[0].x1 = ulx; box[0].y1 = uly;
- X box[0].x2 = lrx; box[0].y2 = uly;
- X
- X box[1].x1 = lrx; box[1].y1 = uly;
- X box[1].x2 = lrx; box[1].y2 = lry;
- X
- X box[2].x1 = lrx; box[2].y1 = lry;
- X box[2].x2 = ulx; box[2].y2 = lry;
- X
- X box[3].x1 = ulx; box[3].y1 = lry;
- X box[3].x2 = ulx; box[3].y2 = uly;
- X
- X
- X /*
- X * If we freeze the screen, don't bother to xor out.
- X */
- X if (Freeze)
- X Leave(4)
- X
- X /*
- X * Xor out.
- X */
- X box[4].x1 = ulx; box[4].y1 = uly;
- X box[4].x2 = lrx; box[4].y2 = uly;
- X
- X box[5].x1 = lrx; box[5].y1 = uly;
- X box[5].x2 = lrx; box[5].y2 = lry;
- X
- X box[6].x1 = lrx; box[6].y1 = lry;
- X box[6].x2 = ulx; box[6].y2 = lry;
- X
- X box[7].x1 = ulx; box[7].y1 = lry;
- X box[7].x2 = ulx; box[7].y2 = uly;
- X
- X
- X /*
- X * Total number of vertices is 8.
- X */
- X Leave(8)
- X}
- END_OF_FILE
- if test 5241 -ne `wc -c <'StoreBox.c'`; then
- echo shar: \"'StoreBox.c'\" unpacked with wrong size!
- fi
- # end of 'StoreBox.c'
- fi
- if test -f 'lockscreen.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'lockscreen.c'\"
- else
- echo shar: Extracting \"'lockscreen.c'\" \(7468 characters\)
- sed "s/^X//" >'lockscreen.c' <<'END_OF_FILE'
- X#ifndef lint
- X static char sccs_id[] = "%W% %H%";
- X#endif
- X
- X/*
- X * XLOCK V1.4
- X *
- X * A Terminal Locker for X11
- X *
- X * Copyright (c) 1988 by Patrick J. Naughton
- X *
- X * All Rights Reserved
- X *
- X * Permission to use, copy, modify, and distribute this software and its
- X * documentation for any purpose and without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and that
- X * both that copyright notice and this permission notice appear in
- X * supporting documentation.
- X *
- X * Original version posted to comp.windows.x by:
- X * Walter Milliken
- X * (milliken@heron.bbn.com)
- X * BBN Advanced Computers, Inc., Cambridge, MA
- X *
- X * Comments and additions may be sent the author at:
- X *
- X * naughton@sun.soe.clarkson.edu
- X *
- X * or by Snail Mail:
- X * Patrick J. Naughton
- X * 23 Pleasant Street, #3
- X * Potsdam, NY 13676
- X * or
- X * (315) 265-2853 (voice)
- X *
- X *
- X * Revision History:
- X * 12-Apr-88: Added root password override.
- X * Added screen saver override.
- X * Removed XGrabServer/XUngrabServer (Bad idea Phil...)
- X * Added access control handling instead.
- X * 01-Apr-88: Added XGrabServer/XUngrabServer for more security.
- X * 30-Mar-88: Removed startup password requirement (why did I add that?)
- X * Removed cursor to avoid phosphor burn.
- X * 27-Mar-88: Rotate fractal by 45 degrees clockwise. (aesthetics)
- X * 23-Mar-88: Added HOPALONG routines from Scientific American Sept. 86 p. 14.
- X * added password requirement for invokation
- X * removed option for command line password
- X * added requirement for display to be "unix:0".
- X * 22-Mar-88: Recieved Walter Milliken's comp.windows.x posting.
- X *
- X * 20-Dec-88: Incorporated into awm. -jkh
- X *
- X */
- X
- X#ifdef LOCKSCR
- X#include <pwd.h>
- X#include <math.h>
- X#include "awm.h"
- X#include <X11/Xutil.h>
- Xchar *crypt();
- Xvoid ReadXString(), lockscreen(), GrabHosts(), UngrabHosts();
- Xvoid iterate(), inithop();
- X
- Xstatic char no_bits[] = {0};
- X
- XWindow w; /* window used to cover screen */
- XGC gc;
- X
- Xunsigned int width; /* width of screen */
- Xunsigned int height; /* height of screen */
- X
- XWindow rootw; /* root window */
- Xint screen; /* current screen */
- XColormap cmap; /* colormap of current screen */
- XCursor mycursor; /* blank cursor */
- X
- Xunsigned long black_pixel; /* pixel value for black */
- Xunsigned long white_pixel; /* pixel value for white */
- XXColor black_color; /* color value for black */
- XXColor white_color; /* color value for white */
- X
- Xint centerx, centery, iter, maxiter, range, color;
- Xdouble a, b, c, i, j;
- X
- XDisplay *dsp;
- X
- X
- Xvoid ReadXString(s, slen)
- Xchar *s;
- Xint slen;
- X{
- X int bp;
- X char c;
- X XEvent evt;
- X XKeyEvent *kpevt = (XKeyEvent *) &evt;
- X char keystr[20];
- X
- X Entry("ReadXString")
- X
- X bp = 0;
- X while (1) {
- X if (XPending(dsp)) {
- X XNextEvent(dsp, &evt);
- X if (evt.type == KeyPress) {
- X if (XLookupString(kpevt, keystr, 20, (KeySym *) NULL,
- X (XComposeStatus *) NULL) > 0) {
- X c = keystr[0];
- X switch (c) {
- X case 8: /* ^H */
- X if (bp > 0) bp--;
- X break;
- X case 13: /* ^M */
- X s[bp] = '\0';
- X Leave_void
- X case 21: /* ^U */
- X bp = 0;
- X break;
- X default:
- X s[bp] = c;
- X if (bp < slen-1) bp++;
- X }
- X }
- X }
- X }
- X else iterate();
- X }
- X Leave_void
- X}
- X
- X
- Xvoid lockscreen(dpy)
- XDisplay *dpy;
- X{
- X char buf[10];
- X char rootpass[10];
- X XSetWindowAttributes attrs;
- X XGCValues xgcv;
- X struct passwd *pw;
- X Pixmap lockc, lockm;
- X int timeout, interval, blanking, exposures; /* screen saver parameters */
- X extern GC XCreateGC();
- X
- X Entry("lockscreen")
- X
- X color = GetBoolRes("lock.useColor", FALSE);
- X dsp = dpy;
- X
- X pw = getpwuid(0);
- X strcpy(rootpass, pw->pw_passwd);
- X
- X rootw = DefaultRootWindow(dsp);
- X screen = DefaultScreen(dsp);
- X width = DisplayWidth(dsp, screen);
- X height = DisplayHeight(dsp, screen);
- X centerx = width / 2;
- X centery = height / 2;
- X range = (int) sqrt((double)centerx*centerx+(double)centery*centery);
- X cmap = DefaultColormap(dsp, screen);
- X
- X black_pixel = BlackPixel(dsp, screen);
- X black_color.pixel = black_pixel;
- X XQueryColor(dsp, cmap, &black_color);
- X
- X white_pixel = WhitePixel(dsp, screen);
- X white_color.pixel = white_pixel;
- X XQueryColor(dsp, cmap, &white_color);
- X
- X attrs.background_pixel = black_pixel;
- X attrs.override_redirect = True;
- X attrs.event_mask = KeyPressMask;
- X w = XCreateWindow(dsp, rootw, 0, 0, width, height, 0,
- X CopyFromParent, InputOutput, CopyFromParent,
- X CWOverrideRedirect | CWBackPixel | CWEventMask, &attrs);
- X
- X lockc = XCreateBitmapFromData(dsp, w, no_bits, 8, 1);
- X lockm = XCreateBitmapFromData(dsp, w, no_bits, 8, 1);
- X mycursor = XCreatePixmapCursor(dsp, lockc, lockm,
- X &black_color, &black_color,
- X 0, 0);
- X XFreePixmap(dsp, lockc);
- X XFreePixmap(dsp, lockm);
- X
- X XMapWindow(dsp, w);
- X
- X xgcv.foreground = white_pixel;
- X xgcv.background = black_pixel;
- X gc = XCreateGC(dsp, w, GCForeground | GCBackground, &xgcv);
- X
- X XGetScreenSaver(dsp, &timeout, &interval, &blanking, &exposures);
- X XSetScreenSaver(dsp, 0, 0, 0, 0); /* disable screen saver */
- X
- X XGrabKeyboard(dsp, w, True, GrabModeAsync, GrabModeAsync, CurrentTime);
- X XGrabPointer(dsp, w, False, -1, GrabModeAsync, GrabModeAsync, None,
- X mycursor, CurrentTime);
- X
- X GrabHosts();
- X
- X pw = getpwuid(getuid());
- X
- X srandom(time(NULL));
- X do {
- X inithop();
- X ReadXString(buf, 10);
- X } while ((strcmp(crypt(buf, pw->pw_passwd), pw->pw_passwd))
- X && (strcmp(crypt(buf, rootpass), rootpass)));
- X
- X UngrabHosts();
- X
- X XUngrabPointer(dsp, CurrentTime);
- X XUngrabKeyboard(dsp, CurrentTime);
- X
- X XSetScreenSaver(dsp, timeout, interval, blanking, exposures);
- X XDestroyWindow(dsp, w);
- X XFlush(dsp);
- X Leave_void
- X}
- X
- XXHostAddress *hosts;
- Xint num_hosts, state;
- X
- Xvoid GrabHosts()
- X{
- X Entry("GrabHosts")
- X
- X XDisableAccessControl(dsp);
- X hosts = XListHosts(dsp, &num_hosts, &state);
- X XRemoveHosts(dsp, hosts, num_hosts);
- X Leave_void
- X}
- X
- X
- Xvoid UngrabHosts()
- X{
- X Entry("UngrabHosts")
- X
- X XEnableAccessControl(dsp);
- X XAddHosts(dsp, hosts, num_hosts);
- X XFree(hosts);
- X Leave_void
- X}
- X
- X
- Xvoid iterate()
- X{
- X double oldj;
- X register int k;
- X
- X Entry("iterate")
- X
- X for (k=0;k<500;k++) {
- X oldj = j;
- X j = a - i;
- X i = oldj + ((i < 0) ? sqrt(fabs(b*i - c)) : -sqrt(fabs(b*i - c)));
- X if (color)
- X XSetForeground(dsp, gc, (iter % 25) * 10 + 5);
- X
- X XDrawPoint(dsp, w, gc,
- X centerx + (int)(i+j), /* sneaky way to rotate +45 deg. */
- X centery - (int)(i-j));
- X iter++;
- X }
- X if (iter > maxiter)
- X inithop();
- X Leave_void
- X}
- X
- Xvoid inithop()
- X{
- X Entry("inithop")
- X
- X a = random() % (range * 100) * (random()%2?-1.0:1.0) / 100.0;
- X b = random() % (range * 100) * (random()%2?-1.0:1.0) / 100.0;
- X c = random() % (range * 100) * (random()%2?-1.0:1.0) / 100.0;
- X
- X if (!(random()%3))
- X a /= 10.0;
- X if (!(random()%2))
- X b /= 100.0;
- X
- X maxiter = (color?10000+random()%20000:20000+random()%50000);
- X iter = 0;
- X i = j = 0.0;
- X XClearWindow(dsp, w);
- X Leave_void
- X}
- X#endif LOCKSCR
- X
- END_OF_FILE
- if test 7468 -ne `wc -c <'lockscreen.c'`; then
- echo shar: \"'lockscreen.c'\" unpacked with wrong size!
- fi
- # end of 'lockscreen.c'
- fi
- if test -f 'menu_sup.c' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'menu_sup.c'\"
- else
- echo shar: Extracting \"'menu_sup.c'\" \(6302 characters\)
- sed "s/^X//" >'menu_sup.c' <<'END_OF_FILE'
- X
- X
- X
- X#ifndef lint
- Xstatic char *rcsid_menu_sup_c = "$Header: /usr/graph2/X11.3/contrib/windowmgrs/awm/RCS/menu_sup.c,v 1.3 89/02/07 22:40:04 jkh Exp $";
- X#endif lint
- X
- X#include "X11/copyright.h"
- X/*
- X *
- X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
- X *
- X * Copyright 1987 by Jordan Hubbard.
- X *
- X *
- X * All Rights Reserved
- X *
- X * Permission to use, copy, modify, and distribute this software and its
- X * documentation for any purpose and without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and that
- X * both that copyright notice and this permission notice appear in
- X * supporting documentation, and that the name of Ardent Computer
- X * Corporation or Jordan Hubbard not be used in advertising or publicity
- X * pertaining to distribution of the software without specific, written
- X * prior permission.
- X *
- X */
- X
- X#include "awm.h"
- X#include <signal.h>
- X#
- X
- X/* interface functions for RTL menus */
- X
- Xdo_nothing() /* like it says... */
- X{
- X}
- X
- XBoolean check_booleans(menu, item)
- XRTLMenu menu;
- XRTLMenuItem item;
- X{
- X Boolean *foo;
- X
- X Entry("check_booleans")
- X
- X foo = (Boolean *)RTLMenu_Data(menu, item);
- X Leave(*foo)
- X}
- X
- XBoolean toggle_booleans(menu, item)
- XRTLMenu menu;
- XRTLMenuItem item;
- X{
- X Boolean *foo;
- X
- X Entry("togglet_booleans")
- X
- X foo = (Boolean *)RTLMenu_Data(menu, item);
- X *foo = !(*foo);
- X Leave(*foo)
- X}
- X
- X/*ARGSUSED*/
- Xint do_shell(menu, item, window) /* Do a shell command */
- XRTLMenu menu;
- XRTLMenuItem item;
- XWindow window; /* not used */
- X{
- X char *cmd;
- X int status, pid, w;
- X void (*istat)(), (*qstat)();
- X
- X Entry("do_shell")
- X
- X cmd = (char *)RTLMenu_Data(menu, item);
- X if ((pid = fork()) == 0) {
- X setpgrp(0, getpid());
- X signal(SIGHUP, SIG_DFL);
- X signal(SIGQUIT, SIG_DFL);
- X signal(SIGINT, SIG_DFL);
- X execl("/bin/sh", "sh", "-c", cmd, 0);
- X _exit(127);
- X }
- X istat = (int (*)())signal(SIGINT, SIG_IGN);
- X qstat = (int (*)())signal(SIGQUIT, SIG_IGN);
- X while ((w = wait(&status)) != pid && w != -1);
- X if (w == -1)
- X status = -1;
- X signal(SIGINT, istat);
- X signal(SIGQUIT, qstat);
- X Leave(status)
- X}
- X
- X/*ARGSUSED*/
- Xint do_text(menu, item, window)
- XRTLMenu menu;
- XRTLMenuItem item;
- XWindow window;
- X{
- X char *buff;
- X
- X Entry("do_text")
- X
- X buff = (char *)RTLMenu_Data(menu, item);
- X XStoreBytes(dpy, buff, strlen(buff));
- X Leave_void
- X}
- X
- X/*ARGSUSED*/
- Xint do_text_nl(menu, item, window)
- XRTLMenu menu;
- XRTLMenuItem item;
- XWindow window;
- X{
- X char *buff1, *buff2;
- X
- X Entry("do_text_nl")
- X
- X buff1 = (char *)RTLMenu_Data(menu, item);
- X buff2 = (char *)malloc(strlen(buff1) + 2);
- X strcpy(buff2, buff1);
- X strcat(buff2, "\n");
- X XStoreBytes(dpy, buff2, strlen(buff2));
- X free(buff2);
- X Leave_void
- X}
- X
- Xint do_awm_func(menu, item, window)
- XRTLMenu menu;
- XRTLMenuItem item;
- XWindow window;
- X{
- X int x, y, button;
- X Boolean (*func)();
- X extern Window Select_Window();
- X
- X Entry("do_awm_func")
- X
- X XSync(dpy, FALSE);
- X if (window == RootWindow(dpy, scr))
- X window = Select_Window(&x, &y, &button);
- X func = (Boolean(*)())RTLMenu_Data(menu, item);
- X Leave((*func)(window, 0, button, x, y))
- X}
- X
- X/*ARGSUSED*/
- Xint do_imm_func(menu, item, window)
- XRTLMenu menu;
- XRTLMenuItem item;
- XWindow window;
- X{
- X Boolean (*func)();
- X
- X Entry("do_imm_func")
- X
- X func = (Boolean(*)())RTLMenu_Data(menu, item);
- X Leave((*func)(RootWindow(dpy, scr), 0, 0, 0, 0))
- X}
- X
- XMenuInfo *FindMenu(s)
- Xregister char *s;
- X{
- X MenuLink *ml;
- X
- X Entry("FindMenu")
- X
- X for (ml = Menus; ml; ml = ml->next)
- X if (!strcmp(s, ml->menu->name))
- X Leave(ml->menu)
- X Leave((MenuInfo *) 0)
- X}
- X
- XRTLMenu create_menu(m)
- XMenuInfo *m;
- X{
- X ActionLine *ln;
- X RTLMenuItem tmp;
- X MenuInfo *side_menu;
- X
- X Entry("create_menu")
- X
- X if (!m)
- X yyerror("Internal error, create_menu passed null pointer");
- X /*
- X * Were we already created? This is possible if we were referenced
- X * by somebody created before us.
- X */
- X if (m->menu)
- X Leave(m->menu)
- X m->menu = RTLMenu_Create();
- X /* make a name (or picture) label for this menu */
- X tmp = RTLMenu_Append_Call(m->menu, m->name, m->pixmapname, do_nothing, 0);
- X RTLMenu_Label_Entry(m->menu, tmp);
- X ln = m->line;
- X if (!ln) {
- X yyerror("Internal error in create_menu.");
- X fprintf(stderr, "Menu '%s' has no line list.\n", m->name);
- X exit(1);
- X }
- X if (!ln->name && !ln->pixmapname) {
- X fprintf(stderr, "awm: Action in menu '%s' has no name or backing pixmap\n",
- X m->name);
- X yyerror(".. aborting\n");
- X exit(1);
- X }
- X while (ln) {
- X switch (ln->type) {
- X case IsVar:
- X ln->item = RTLMenu_Append_Checkback(m->menu, ln->name,
- X ln->pixmapname,
- X check_booleans,
- X toggle_booleans,
- X ln->text);
- X break;
- X
- X case IsImmFunction:
- X ln->item = RTLMenu_Append_Call(m->menu, ln->name,
- X ln->pixmapname,
- X do_imm_func, ln->func);
- X break;
- X
- X case IsUwmFunction:
- X ln->item = RTLMenu_Append_Call(m->menu, ln->name,
- X ln->pixmapname,
- X do_awm_func, ln->func);
- X break;
- X
- X case IsMenuFunction:
- X if (!(side_menu = FindMenu(ln->text))) {
- X fprintf(stderr, "Unknown menu \"%s\" referenced in ",
- X ln->text);
- X yyerror(" ..");
- X exit(1);
- X }
- X /* If we haven't created the referenced menu yet, create it now */
- X if (!side_menu->menu)
- X side_menu->menu = create_menu(side_menu);
- X ln->item = RTLMenu_Append_Submenu(m->menu, ln->name,
- X ln->pixmapname,
- X side_menu->menu);
- X break;
- X
- X case IsText:
- X ln->item = RTLMenu_Append_Call(m->menu, ln->name,
- X ln->pixmapname,
- X do_text, ln->text);
- X break;
- X
- X case IsTextNL:
- X ln->item = RTLMenu_Append_Call(m->menu, ln->name,
- X ln->pixmapname,
- X do_text_nl, ln->text);
- X break;
- X
- X case IsShellCommand:
- X ln->item = RTLMenu_Append_Call(m->menu, ln->name,
- X ln->pixmapname,
- X do_shell, ln->text);
- X break;
- X
- X default:
- X fprintf(stderr, "create_menu, Unknown menu entry type %d\n",
- X ln->type);
- X break;
- X }
- X free(ln);
- X ln = ln->next;
- X }
- X Leave(m->menu)
- X}
- END_OF_FILE
- if test 6302 -ne `wc -c <'menu_sup.c'`; then
- echo shar: \"'menu_sup.c'\" unpacked with wrong size!
- fi
- # end of 'menu_sup.c'
- fi
- if test -f 'menus/arrow_icon.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'menus/arrow_icon.h'\"
- else
- echo shar: Extracting \"'menus/arrow_icon.h'\" \(191 characters\)
- sed "s/^X//" >'menus/arrow_icon.h' <<'END_OF_FILE'
- X
- X#define arrow_width 10
- X#define arrow_height 9
- Xstatic char arrow_bits[] = {
- X 0x30, 0x00, 0x60, 0x00, 0xff, 0x00, 0xc0, 0x01, 0x9e, 0x03, 0xc0, 0x01,
- X 0xff, 0x00, 0x60, 0x00, 0x30, 0x00};
- END_OF_FILE
- if test 191 -ne `wc -c <'menus/arrow_icon.h'`; then
- echo shar: \"'menus/arrow_icon.h'\" unpacked with wrong size!
- fi
- # end of 'menus/arrow_icon.h'
- fi
- if test -f 'menus/menu.h' -a "${1}" != "-c" ; then
- echo shar: Will not clobber existing file \"'menus/menu.h'\"
- else
- echo shar: Extracting \"'menus/menu.h'\" \(6154 characters\)
- sed "s/^X//" >'menus/menu.h' <<'END_OF_FILE'
- X
- X/*
- X#ifndef lint
- Xstatic char sccs_id[] = "@(#)menu.h 2.1 12/16/87 Siemens Corporate Research and Support, Inc.";
- X#endif
- X*/
- X
- X
- X/*
- X RTL Menu Package Version 1.0
- X by Joe Camaratta and Mike Berman, Siemens RTL, Princeton NJ, 1987
- X
- X menu.h: menus header file
- X based on: menu.h X10/6.6 11/3/86
- X*/
- X
- X#include "X11/copyright.h"
- X/*
- X *
- X * Copyright 1987, 1988 by Ardent Computer Corporation, Sunnyvale, Ca.
- X *
- X * Copyright 1987 by Jordan Hubbard.
- X *
- X *
- X * All Rights Reserved
- X *
- X * Permission to use, copy, modify, and distribute this software and its
- X * documentation for any purpose and without fee is hereby granted,
- X * provided that the above copyright notice appear in all copies and that
- X * both that copyright notice and this permission notice appear in
- X * supporting documentation, and that the name of Ardent Computer
- X * Corporation or Jordan Hubbard not be used in advertising or publicity
- X * pertaining to distribution of the software without specific, written
- X * prior permission.
- X *
- X */
- X
- X/*
- X
- XCopyright 1985, 1986, 1987 by the Massachusetts Institute of Technology
- X
- XPermission to use, copy, modify, and distribute this
- Xsoftware and its documentation for any purpose and without
- Xfee is hereby granted, provided that the above copyright
- Xnotice appear in all copies and that both that copyright
- Xnotice and this permission notice appear in supporting
- Xdocumentation, and that the name of M.I.T. not be used in
- Xadvertising or publicity pertaining to distribution of the
- Xsoftware without specific, written prior permission.
- XM.I.T. makes no representations about the suitability of
- Xthis software for any purpose. It is provided "as is"
- Xwithout express or implied warranty.
- X
- X*/
- X
- X/*
- X
- XCopyright 1987 by
- X Siemens Corporate Research and Support, Inc., Princeton, New Jersey
- X
- XPermission to use, copy, modify, and distribute this
- Xsoftware and its documentation for any purpose and without
- Xfee is hereby granted, provided that the above copyright
- Xnotice appear in all copies and that both that copyright
- Xnotice and this permission notice appear in supporting
- Xdocumentation, and that the name of Siemens not be used in
- Xadvertising or publicity pertaining to distribution of the
- Xsoftware without specific, written prior permission.
- XSiemens makes no representations about the suitability of
- Xthis software for any purpose. It is provided "as is"
- Xwithout express or implied warranty.
- X
- X*/
- X
- X#ifndef MENU_INCLUDE
- X#define MENU_INCLUDE
- X/*
- X * Menu items are constructed as follows, starting from the left side:
- X *
- X * menuItemPad
- X * space for check mark
- X * menuItemPad
- X * text + padding
- X * menuItemPad
- X *
- X * The padding for the text is that amount that this text is narrower than the
- X * widest text.
- X */
- Xextern void Retch();
- X
- X#include "std_defs.h"
- X#include "rtlmnu.opt.h"
- X
- Xtypedef void (*Callback) ();
- Xtypedef struct _menuItem MenuItem;
- Xtypedef struct _menu Menu;
- X
- X/*
- X * Special note for those familiar with the original RTL menus:
- X * Where we used to keep height and width information for items
- X * in the _menu structure, we now just keep width. Each item
- X * can be of a different height, but is still constrained
- X * to a fixed width (which is the width of the widest item in the
- X * menu). We could allow variable widths, but the menu would look
- X * like hell. We also allow arbitrary pixmap backgrounds for each
- X * item now.
- X */
- Xstruct _menuItem {
- X int itemFlags; /* flags of item */
- X
- X#define itemDisabled 0x0001 /* item is disabled */
- X#define itemChecked 0x0002 /* item has check mark */
- X#define itemDeaf 0x0004 /* item is a label */
- X#define itemChanged 0x0010 /* item desires change */
- X Pixmap itemBackground; /* either zero or a pixmap */
- X char *itemText; /* text of item (if no pixmap) */
- X unsigned int itemTextWidth; /* width of text (or pixmap) */
- X unsigned int itemTextLength; /* length of text */
- X unsigned int itemHeight; /* height of this item */
- X struct _menuItem *nextItem; /* next item in chain */
- X struct _menu *itemSubmenu; /* For pull-right menus */
- X Callback generator; /* Change string and data */
- X caddr_t genParamPointer; /* Address for generated parameter */
- X Boolean (*checkproc) (); /* Checkmark callback generator */
- X Callback itemCallback; /* user callback for item */
- X pointer itemData; /* user data associated with menu */
- X Window itemWindow; /* window of item */
- X Menu *itemMenu; /* menu this item belongs to */
- X};
- X
- Xstruct _menu {
- X unsigned int menuWidth; /* full width of menu */
- X unsigned int menuHeight; /* full height of menu */
- X unsigned int avgHeight; /* Hack.. */
- X unsigned int menuOldWidth;
- X unsigned int menuOldHeight;
- X unsigned int menuItemWidth; /* width of a menu item */
- X int menuFlags; /* flags of this menu */
- X
- X# define menuChanged 0x0001 /* menu changed, must redraw */
- X# define menuItemChanged 0x0002 /* item changed, must redraw */
- X# define menuMapped 0x0004 /* menu is now mapped */
- X
- X unsigned int menuMaxTextWidth; /* width of widest text */
- X unsigned int menuOldBorderWidth;
- X Display *display; /* display of menu */
- X int screen; /* screen on which to display menu */
- X Window menuWindow; /* window of menu */
- X Cursor menuCursor; /* cursor used in menu */
- X Pixmap savedPixmap; /* for saving image under menu */
- X MenuItem *menuItems; /* head of menu item chain */
- X XFontStruct *menuFontInfo; /* Font info */
- X XFontStruct *boldFont;
- X GC normalGC; /* Graphics contexts */
- X GC invertGC; /* Used for inverted text */
- X GC boldGC; /* For labels */
- X Pixmap greyPixmap; /* Need to know what to free */
- X Pixmap checkmarkPixmap; /* Pixmap for drawing check mark. */
- X Pixmap arrowPixmap; /* Pixmap for drawing arrow. */
- X char *menuInitialItemText; /* != NULL, initial item */
- X MenuItem *highlightedItem; /* highlighted menu item */
- X int menuNested; /* depth you are nested */
- X int menuX, menuY; /* Menu position */
- X struct _menu *parentMenu; /* menu to which you are a submenu
- X * (NULL if you are the root)
- X */
- X MenuOptionsMask menuOptions; /* option values for this menu */
- X };
- X#endif MENU_INCLUDE
- END_OF_FILE
- if test 6154 -ne `wc -c <'menus/menu.h'`; then
- echo shar: \"'menus/menu.h'\" unpacked with wrong size!
- fi
- # end of 'menus/menu.h'
- fi
- echo shar: End of archive 9 \(of 12\).
- cp /dev/null ark9isdone
- MISSING=""
- for I in 1 2 3 4 5 6 7 8 9 10 11 12 ; do
- if test ! -f ark${I}isdone ; then
- MISSING="${MISSING} ${I}"
- fi
- done
- if test "${MISSING}" = "" ; then
- echo You have unpacked all 12 archives.
- rm -f ark[1-9]isdone ark[1-9][0-9]isdone
- else
- echo You still need to unpack the following archives:
- echo " " ${MISSING}
- fi
- ## End of shell archive.
- exit 0
- --
- Mike Wexler(wyse!mikew) Phone: (408)433-1000 x1330
- Moderator of comp.sources.x
-